#ifndef __APP_LOG_H_
#define __APP_LOG_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "project_config.h"
#include <dbug.h>
#include <NetworkPort.h>
#include <DTU_Opt.h>
#include <sys/time.h>

extern bool_t ctime_normal(s64 timep, char *buf);

#define DTU_InfoLog(module,fmt, ...) do{\
char DateTime[24];\
memset(DateTime,0,sizeof(DateTime));\
ctime_normal(Time_Time(NULL), DateTime);\
if (DTU_GetRealTimeUploadFlag() != (0)) \
{\
    char InfoLog[128];\
    snprintf(InfoLog, sizeof(InfoLog), "info : %s:%d:[%s] : "fmt"", __func__, __LINE__, DateTime, ##__VA_ARGS__);\
    DTU_UploadRealtimeLog(InfoLog);\
}\
info_printf(module, "[%s]:"fmt"", DateTime, ##__VA_ARGS__);\
}while (0)

#define DTU_ErrLog(module,fmt, ...) do{\
char DateTime[24];\
memset(DateTime,0,sizeof(DateTime));\
ctime_normal(Time_Time(NULL), DateTime);\
if (DTU_GetRealTimeUploadFlag() != (0)) \
{\
    char ErrLog[128];\
    snprintf(ErrLog, sizeof(ErrLog), "err : %s:%d:[%s] : "fmt"", __func__, __LINE__, DateTime, ##__VA_ARGS__);\
    DTU_UploadRealtimeLog(ErrLog);\
}\
error_printf(module, "[%s]:"fmt"", DateTime, ##__VA_ARGS__);\
}while (0)

#define DTU_DebugLog(module,fmt, ...) do{\
char DateTime[24];\
memset(DateTime,0,sizeof(DateTime));\
ctime_normal(Time_Time(NULL), DateTime);\
debug_printf(module, "[%s]:"fmt"", DateTime, ##__VA_ARGS__);\
}while (0)

#ifdef __cplusplus
}
#endif

#endif
